var ZYRequestClient = require("../../../../utils/zy-request");
var requestClient;
const app = getApp();
Page({
  data:{
    companyId:0,
    companyName:'',
    navbarData:{
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '邀请人员', //导航栏 中间的标题
      white:true
     },
     // 导航头的高度
     height: app.globalData.height * 2 + 20
  },
  onLoad(options) {
    requestClient = new ZYRequestClient();
    var _this = this;
    var userInfo = wx.getStorageSync('userInfo');
    if(userInfo == ''){
      wx.showModal({
        title:'请授权登录！',
        content:'您还未授权登录，请在授权登录后再邀请人员！',
        showCancel:false,
        success(r){
          wx.reLaunch({
            url: '../../../login/index',
          })
        }
      })
    } else {
      _this.setData({
        companyId:parseInt(options.companyId),
        inviteUserId:parseInt(userInfo.id)
      });
      requestClient.getCompanyInfo(_this.data.companyId,function(res){
        _this.setData({
          companyName:res.data.data.name
        });
      })
      requestClient.checkFunctionPermission(3001,'您没有权限邀请人员，请联系企业创建者！',function(){},function(){
        wx.navigateBack({
          delta: 1,
        })
      });
    }
  },
  onShareAppMessage:function(res){
      var _this = this;
      return {
        title:"邀请人员",
        path:"/pages/tabbar/mine/joincompany/index?companyInfo={\"id\":" + _this.data.companyId + ",\"name\":\"" + _this.data.companyName + "\"}"
      }
  }
})